<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
    <title>登录页面</title>
    <%@include file="common/common.jsp" %>
</head>
<script src="${path}/static/js/jquery.placeholder.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('input, textarea').placeholder();
        //生成验证码
        $('#kaptchaImage').click(function () {
            $(this).hide().attr('src', '${path}/code/captcha-image?' + Math.floor(Math.random() * 100)).fadeIn();
        });
    });

    window.onbeforeunload = function () {
        //关闭窗口时自动退出
        if (event.clientX > 360 && event.clientY < 0 || event.altKey) {
            alert(parent.document.location);
        }
    };

    function changeCode() {  //刷新
        $('#kaptchaImage').hide().attr('src', '${path}/code/captcha-image?' + Math.floor(Math.random() * 100)).fadeIn();
        event.cancelBubble = true;
    }

    function upload() {
        $.ajax({
            url: "${path}/userInfo/upload",
            success: function () {
                console.info("success");
            },
            error: function () {
                console.info("error");
            }
        });
    }

    function upload2() {
        $.ajax({
            url: "${path}/userInfo/upload2",
            success: function () {
                console.info("success");
            },
            error: function () {
                console.info("error");
            }
        });
    }

    function down() {
        $.ajax({
            url: "${path}/userInfo/down",
            success: function () {
                console.info("success");
            },
            error: function () {
                console.info("error");
            }
        });
    }

</script>
<style>
    .placeholder { color: #aaa; }
    input{
        width: 160px;
    }
</style>
<body>
<form action="${path}/login" method="post">
    username:<input type="text" name="userName" id="login_username"><br>
    password:<input type="password" name="password" id="login_password"><br>
    <div class="form-group">
        <label>验证码 </label>
        <input name="j_code" type="text" id="kaptcha" maxlength="4" class="form-control"/>
        <br/>
        <img src="${path}/code/captcha-image" id="kaptchaImage" style="margin-bottom: -3px"/>
        <a href="#" onclick="changeCode()">看不清?换一张</a>
    </div>

    <input type="submit" value="登录">
</form>

<a href="javascript:void(0)"  onclick="javascript:upload()">上传</a>
<a href="javascript:void(0)"  onclick="javascript:upload2()">上传2</a>
<a href="javascript:void(0)"  onclick="javascript:down()">下载</a>
${errorMsg}
</body>
</html>
